package com.rpframework.website.device.service;

import java.util.List;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;

import com.rpframework.core.BaseService;
import com.rpframework.utils.NumberUtils;
import com.rpframework.utils.Pager;
import com.rpframework.website.device.dao.IRoomDao;
import com.rpframework.website.device.domain.Estate;
import com.rpframework.website.device.domain.Room;

@Service
public class RoomService extends BaseService{
	public @Resource IRoomDao iDao;
	
	public Pager<Room> getPager(Pager<Room> pager) {
		long startTime = System.currentTimeMillis();
		List<Room> list = iDao.doPager(this.packageMyBatisParam(pager));
		pager.setItemList(list);
		pager.setCostTime(System.currentTimeMillis() - startTime);
		return pager;
	}

	public boolean doSaveOrUpdate(Room t) {
		if(NumberUtils.isValid(t.getId())){
			t.setModifyTime(System.currentTimeMillis()/1000);
			return iDao.update(t);
		}
		t.setCreateTime(System.currentTimeMillis()/1000);
		return insert(t);
	}
}
